package com.pubinfo.passbook.engine.cell.single;

import com.pubinfo.passbook.common.model.http.engine.ComputeParamSlot;
import com.pubinfo.passbook.engine.constants.ComputeChainType;
import com.pubinfo.passbook.engine.constants.ComputeResultType;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collection;

/**
 * 强制覆盖当前计算结果
 *
 * @author zhouch
 * @date 2022/1/27 11:34
 */
public class AssignUnit<T> extends ComputeSingleUnit<T> {

    /**
     * 参数名称: value
     * 返回值类型: 数值
     */
    private static final ComputeParamSlot ASSIGN_PARAM_SLOT = ComputeParamSlot.of("value", ComputeResultType.NUMBER);

    @Override
    public Collection<ComputeParamSlot> getParamSlots() {
        return Arrays.asList(
                ASSIGN_PARAM_SLOT
        );
    }


    @Override
    public BigDecimal compute(T data, BigDecimal result) {
        return getParamenter(data, ASSIGN_PARAM_SLOT.getName());
    }

    @Override
    public String getChainType() {
        return ComputeChainType.COMMON;
    }

    @Override
    public String getResultType() {
        return ComputeResultType.NUMBER;
    }
}
